<%@ page session="false" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

<tr:panelGroupLayout>
<fieldset>
<legend>Załączniki</legend>

 <tr:panelHorizontalLayout>
			  	<tr:commandLink shortDesc="Wczytaj plik" useWindow="false" blocking="true" id="uploadFile"
                     			action="dialog:fileupload" windowHeight="150" windowWidth="250"
                                      returnListener="#{orderController.updateAttachmentState}">
                       <tr:image source="gfx/add_button.png" />
        		</tr:commandLink>
</tr:panelHorizontalLayout>
		
<div style="width:100%">		
	<table style="width:100%">

		<tr:iterator value="#{orderBean.attachmentList}"
					binding="#{orderController.attachmentIterator}" 
					id="list" var="file">
			<tr onMouseOver="this.style.backgroundColor='#e0ffc2'" onMouseOut="this.style.backgroundColor='#FFF'">
				<td>
				<tr:commandLink text="#{file.name}  (#{file.capacity}B)" shortDesc="Pobierz plik"
									actionListener="#{orderController.selectAttachment}" />
				</td>
				<td align="right">
				<tr:panelGroupLayout layout="horizontal">
				<tr:outputText value="#{file.creationDateFormated}" />
				<tr:commandLink actionListener="#{orderController.removeAttachment}"
								rendered="#{not SessionDataTO.readOnly}"
								onclick="return confirmMessageBox('Czy chcesz usunąć załącznik #{file.name} ?');"
								shortDesc="Usuń plik">
						<tr:image source="gfx/delete.png" />
				</tr:commandLink>
				
				</tr:panelGroupLayout>
				</td>
			</tr>
		</tr:iterator>
	</table>
</div>
	</fieldset>
</tr:panelGroupLayout>